home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / cmouse.exe / CMOUSE.DOC < prev    next >
Text File  |  1991-07-27  |  8KB  |  215 lines

  1.     Cmouse.cpp for Borland C++
  2.     ==========================
  3.  
  4.  
  5.     Thank you for downloading cmouse.zip.  Compile cmoused.cpp, 
  6.     cmouse.cpp and link with graphics.lib.  Then run the demo 
  7.     cmoused.exe.  A mouse interrupt handler is provided and 
  8.     should serve most all your needs.
  9.  
  10.     The MicrosoftMouse class provides member functions for all 
  11.     Microsoft Mouse Driver functions packaged in a convenient 
  12.     interface.  Do not instantiate any instances of the class - 
  13.     instead access them through MM, the only instance of 
  14.     MicrosoftMouse!
  15.  
  16.     For example:
  17.  
  18.     #include <stdio.h>
  19.     #include <cmouse.hpp>
  20.  
  21.     main()
  22.     {
  23.         MM.open();  // initialize mouse
  24.         MM.show();
  25.         MM.autoEventUpdate();
  26.         while (!MM.leftPressed) do;
  27.         puts("Mouse's left button pressed.");
  28.         MM.close(); // clear mouse
  29.         return 0;
  30.     }
  31.  
  32.     All cmouse coordinates are expressed in Borland C++'s 
  33.     physical screen coordinates rather than the mouse's virtual 
  34.     coordinates.  Be sure to call MM.reset() after each video 
  35.     mode change to enable this feature!
  36.  
  37.     MM is a global instance of the MicrosoftMouse class. Since it 
  38.     has no constructor or destructor, you must first call 
  39.     MM.open() to prepare the mouse for use and MM.close() when 
  40.     finished with the mouse.  A constructor and destructor were 
  41.     not used because the interrupt setting calls conflict with 
  42.     C++ startup and exit code outside of main in some memory 
  43.     models.  Since MM is global, its constructor and destructor 
  44.     would be called outside of main(). 
  45.  
  46.     Look at the MicrosoftMouse class declaration in cmouse.hpp.  
  47.     You will soon notice that the member functions don't 
  48.     typically pass parameters but values are instead stored 
  49.     directly in the MM instance's data fields.  The reason I 
  50.     don't pass parameters is so you don't have to provide 
  51.     variables to store them in. Secondly, cmouse has a special 
  52.     function called autoEventUpdate() that activates a prewritten 
  53.     mouse event interrupt handler.  All you do is call 
  54.     MM.autoEventUpdate() and it updates the MM's data fields 
  55.     whenever a mouse event happens as specified by MM.eventMask.  
  56.     The mask is preconfigured to request an update whenever the 
  57.     mouse moves, or a mouse button is pressed or released.  That 
  58.     way your application simply poles these fields for updates.  
  59.     This should satisfy most of your requirements.  If you need 
  60.     something more sophisticated, you can use the code of 
  61.     autoEventHandler() to cookbook your own interrupt handler!
  62.  
  63.     For example:
  64.  
  65.  
  66.     MM.x = 10; MM.y = 20; MM.gotoxy();
  67.  
  68.     // moves the mouse cursor to (10,20).
  69.  
  70.  
  71.     MM.updateStatusInfo()
  72.     if (MM.leftPressed)
  73.         // if left button pressed.
  74.  
  75.  
  76.     If you are wondering what the total effect of calling 
  77.     MM.updateStatusInfo() is you can study the source.  If you 
  78.     want to do any serious mouse programming it would be a good 
  79.     idea to pick up
  80.  
  81.     "Microsoft Mouse Programmer's Reference."
  82.         Bellevue, Washington: Microsoft Press, 1989.
  83.  
  84.     This is the main reference I used in coding cmouse.  Rather 
  85.     than repeat what is in this book or explain what the mouse 
  86.     functions do, you should reference this book.  By using the 
  87.     book and reading the header of cmouse, you will soon get the 
  88.     picture of what's going on.
  89.  
  90.  
  91.     Of course if you had activated the provided mouse interrupt 
  92.     handler, all you would have to do to see if the left button 
  93.     was pressed is test the field:
  94.  
  95.  
  96.     if (MM.leftPressed)
  97.         // if left button pressed.
  98.  
  99.  
  100.     To enable the mouse interrupt handler, you must call 
  101.     MM.autoEventUpdate().  Check the demo code to see if you can 
  102.     find this.  Also study the display of the demo.  It displays 
  103.     many of the fields of MM.  Use the mouse and see how these 
  104.     fields register the changes. The function MouseReport() in 
  105.     the demo produces this report.  Look there to see how the 
  106.     fields are accessed.
  107.  
  108.  
  109.     I have tested the omouse unit with Microsoft Mouse driver 
  110.     version 7.00 and Microsoft's second generation serial mouse 
  111.     as well as the ATI VGA Wonder Plus bus mouse.  If the demo 
  112.     won't run in graphics mode the most likey cause is your mouse 
  113.     driver doesn't support the more advanced features of your 
  114.     graphics card.  I know, you have a paint program that works 
  115.     fine with your mouse and driver so it must be cmouse.  Well 
  116.     many paint programs provide their own built-in drivers to 
  117.     keep you from calling them with the same problem.  Believe 
  118.     me, call your mouse manufacturer and get the latest driver.  
  119.     If you must call me, don't call in the middle of the night, 
  120.     please!
  121.  
  122.  
  123.     Super VGA Modes
  124.     ===============
  125.  
  126.     At this time I am awaiting information from VESA for VESA 
  127.     compliant SVGA modes.  When I do I'll update cmouse for those 
  128.     modes.  In the mean time if you want to try it yourself you 
  129.     must modify Xcell[], Ycell[], LeftTopOfs[], virtualX(), 
  130.     virtualY(), physicalX(), and physicalY().  The standard modes 
  131.     documented in the Microsoft Mouse Programmer's Reference are 
  132.     for video modes 0-13 hex.  This made it easy to implement 
  133.     Xcell, Ycell, and LeftTopOfs in arrays.  I'm thinking that I 
  134.     will simply remap modes 23, 27, 33, 37, 54, 6A, 61, 62, 63, 
  135.     65, and 67 hex into MM.vmode just above 13 hex so that these 
  136.     arrays can simply be extended.  I use these arrays to 
  137.     automatically convert between physical screen coordinates and 
  138.     mouse virtual coordinates.
  139.  
  140.  
  141.  
  142.     Registration
  143.     ============
  144.  
  145.     If you find cmouse useful and are using it in your 
  146.     applications, tell your friends.  You don't need to register 
  147.     cmouse -- it's freeware!  All I ask is that you leave my 
  148.     copyright notice intact!
  149.  
  150.  
  151.  
  152.  
  153.     Thanks again!
  154.  
  155.  
  156.     John W. Small
  157.     Voice: (703) 759-3838
  158.     CIS: 73757,2233
  159.  
  160.     PSW / Power SoftWare
  161.     P.O. Box 10072
  162.     McLean, VA 22102 8072
  163.     (703) 759-3838
  164.  
  165.  
  166.  
  167.          ----------------end-of-author's-documentation---------------
  168.  
  169.                          Software Library Information:
  170.  
  171.                     This disk copy provided as a service of
  172.  
  173.                            Public (software) Library
  174.  
  175.          We are not the authors of this program, nor are we associated
  176.          with the author in any way other than as a distributor of the
  177.          program in accordance with the author's terms of distribution.
  178.  
  179.          Please direct shareware payments and specific questions about
  180.          this program to the author of the program, whose name appears
  181.          elsewhere in  this documentation. If you have trouble getting
  182.          in touch with the author,  we will do whatever we can to help
  183.          you with your questions. All programs have been tested and do
  184.          run.  To report problems,  please use the form that is in the
  185.          file PROBLEM.DOC on many of our disks or in other written for-
  186.          mat with screen printouts, if possible.  PsL cannot debug pro-
  187.          programs over the telephone, though we can answer questions.
  188.  
  189.          Disks in the PsL are updated  monthly,  so if you did not get
  190.          this disk directly from the PsL, you should be aware that the
  191.          files in this set may no longer be the current versions. Also,
  192.          if you got this disk from another vendor and are having prob-
  193.          lems,  be aware that  some files may have become corrupted or
  194.          lost by that vendor. Get a current, working disk from PsL.
  195.  
  196.          For a copy of the latest monthly software library newsletter
  197.          and a list of the 3,000+ disks in the library, call or write
  198.  
  199.                            Public (software) Library
  200.                                P.O.Box 35705 - F
  201.                             Houston, TX 77235-5705
  202.  
  203.                                  Orders only:
  204.                                 1-800-2424-PSL
  205.                               MC/Visa/AmEx/Discover
  206.  
  207.                           Outside of U.S. or in Texas
  208.                           o